//
// Created by redcat1 on 12.05.2024.
//

#include "figures.h"
#include <cmath>

//
double Rectangle_Area(Rectangle* rect)
{
  return rect->length * rect->width;
}

//
double Rectangle_Perimeter(Rectangle* rect)
{
  return 2. * (rect->length + rect->width);
}

//
double Circle_Area(Circle* circle)
{
  return M_PI * circle->radius * circle->radius;
}

//
double Circle_Perimeter(Circle* circle)
{
  return 2. * M_PI * circle->radius;
}

//
double RightTriangle_Area(RightTriangle* triangle)
{
  return triangle->leg1 * triangle->leg2 / 2.;
}

//
double RightTriangle_Perimeter(RightTriangle* triangle)
{
  return triangle->leg1 + triangle->leg2 + std::hypot(triangle->leg1, triangle->leg2);
}
